
#Replication code for "From Public Service Access to Service Quality: The Distributive Politics of Piped Water in Bangalore", Tanu Kumar et. al.

rm(list=ls())

#Uncomment lines to install the packages
# install.packages('stargazer')
# install.packages("plyr")
# install.packages("ggplot2")
# install.packages("MASS")
# install.packages("Hmisc")
# install.packages("reshape2")
# install.packages("plyr")
# install.packages("tmap")
# install.packages("raster")
# install.packages("rgdal")
# install.packages("clusterSEs")
# install.packages("arm")
# install.packages("rms")
# install.packages('tidyverse')
# install.packages("dplyr")

library('stargazer')
library("plyr")
library("ggplot2")
library("MASS")
library("Hmisc")
library("reshape2")
library("plyr")
library("tmap")
library("raster")
library("rgdal")
library("clusterSEs")
library("arm")
library("rms")
library('tidyverse')
library("dplyr")
set.seed(12345)

#Set working directory and load data

setwd("~/replication")

load('final_data.Rdata')

valves<- readOGR(dsn = "valve_areas") #imports valve area shape files#


# Table 3. Descriptive Statistics for Independent Variables ---------------

##Household level variables##
summary1=data[,c('elevation','cauvery_only',
                 'muslim_family','low_income_veh','urbanmigrant',"SCST2","congress")] 

stargazer(summary1, type='text', title="Descriptive statistics for independent variables", nobs = FALSE,
          covariate.labels=c( "Elevation","Cauvery Supply",  "Muslim",
                              'Low income', "Urban migrant", "SC/ST", "Congress supporter"))


##Valve area level variables##
summary2=unique(data[,c('VA_muslim',
  'VA_urbanmigrant', 'VA_lowincome_veh' , 'VA_local_leader','VA_SCST2','VA_congress')])

stargazer(summary2, type='text', title="Descriptive statistics for VA level independent variables ", nobs = FALSE,
          covariate.labels=c(  "Muslim", "Urban Migrant",
                              'Low income',"Local Leader", "SCST", "Congress supporter"))


##Ward level variables##
summary3=unique(data[,c('comp', 'CorporatorAlignmentPre')])

stargazer(summary3, type='text', title="Descriptive statistics for  Ward level independent variables", nobs = FALSE,
          covariate.labels=c( "Margin of victory", "INC Corporator"))



# Table 4. Tabulated Responses for Dependent Variables --------------------
#Whether water comes at a specific time
with(data, table(fct_rev(Q209_water_time_factor)))

#Interval between supply days
with(data, table(fct_rev(Q205_pipedwaterdays_factor)))


#Duration of water when it comes on
with(data, table(fct_rev(Q208_decimal_wateron_factor)))

#Whether or not serice is cancelled on supply days

with(data, table(fct_rev(Q213_waterarrival_factor)))


#Water pressure level
with(data, table(fct_rev(Q220a_pressure_factor)))



# Table 5. Spearman rank correlation matrix   --------

DV=as.data.frame(cbind(rank(data$Q209_water_time_factor),rank(data$Q205_pipedwaterdays_factor),
                       rank(data$Q208_decimal_wateron_factor),rank(data$Q213_waterarrival_factor),
                       rank(data$Q220a_pressure_factor)))
colnames(DV)=c('Predictability','Service Frequency', 'Duration','Cancellations','Pressure')

cor(DV, method='spearman')%>%round(.,digits=2)

#Figure 3. Day Intervals Between Water Supply in BWSSB Subdivision E3 --------

#top panel
a=tm_shape(valves) + 
  tm_fill("scheduled", palette="Greys", title="Interval (Days)", colorNA=NULL)+tm_layout(main.title="Scheduled Interval Between Supply Days")+
  tm_layout(legend.outside = TRUE)

#bottom panel
b=tm_shape(valves) + 
  tm_fill("reported", palette="Greys", title="Interval (Days)", colorNA=NULL)+tm_layout(main.title="Reported Interval Between Supply Days")+
  tm_layout(legend.outside = TRUE)

#print full figure
tmap_arrange(a,b)



# Table 6. Predictability of Water Supply ---------------------------------

#Output will be printed at the end. For all models, coefficients are estimated in one step, after which standard errors
#are estimated using a bootstrap resampling method

#Model 1
fm1m1 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader , data=data, x=TRUE, y=TRUE)
fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)


#Model 2
fm1m2 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader+
               Ward, data=data, x=TRUE, y=TRUE)
fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)




#Model 3
fm1m3 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)
fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)




#Model 4

fm1m4 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader+
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)
fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40, 
                     coef.reps=TRUE)



stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Whether water arrives at a specific time "),
          covariate.labels=c("Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                             'Low income',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                             'Low Income (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))


#Figure 4.  Predicted probability for whether water comes at a specific time (Model 1)--------------- 
dd = datadist(data)
options(datadist="dd")
dd$limits$elevation[2]=mean(data$elevation, na.rm= TRUE)
dd$limits$cauvery_only[2]=mean(data$cauvery_only, na.rm= TRUE)
dd$limits$muslim_family[2]=mean(data$muslim_family, na.rm= TRUE)
dd$limits$urbanmigrant[2]=mean(data$muslim_family, na.rm= TRUE)
dd$limits$low_income_veh[2]=mean(data$low_income_veh, na.rm= TRUE)
dd$limits$VA_muslim[2]=mean(data$VA_muslim, na.rm= TRUE)
dd$limits$VA_urbanmigrant[2]=mean(data$VA_urbanmigrant, na.rm= TRUE)
dd$limits$VA_local_leader[2]=mean(data$VA_local_leader, na.rm= TRUE)

fm1m1clus.=update(fm1m1clus)

ggplot(Predict(fm1m1clus., VA_lowincome_veh, fun=plogis),adj.subtitle = FALSE)+labs(y='Predicted Probability',title=" ", x='% Low income households in a valve area' )

#Table 7. Water Supply Frequency-------

#Model 1
fm1m1 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader, data=data, x=TRUE, y=TRUE)

fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)



#Model 2
fm1m2 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               Ward, data=data, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)


#Model 3


fm1m3 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)




#Model 4

fm1m4 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40)




stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Number of days a week with supply"),
          covariate.labels=c( covariate.labels=c("y> =every 4-5 days", "y> =every 3-4 days", 'y> =every 2 days',"y>=everyday","Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                                                 'Low income',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                                                 'Low Income (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
                              
                             'Urban Migrant', 'Low Income', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies?", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))

#Figure 5. Predicted probability for water supply frequency----- 

dd = datadist(data)
options(datadist="dd")
dd$limits$elevation[2]=mean(data$elevation, na.rm= TRUE)
dd$limits$cauvery_only[2]=mean(data$cauvery_only, na.rm= TRUE)
dd$limits$muslim_family[2]=mean(data$muslim_family, na.rm= TRUE)
dd$limits$urbanmigrant[2]=mean(data$muslim_family, na.rm= TRUE)
dd$limits$low_income_veh[2]=mean(data$low_income_veh, na.rm= TRUE)
dd$limits$VA_muslim[2]=mean(data$VA_muslim, na.rm= TRUE)
dd$limits$VA_urbanmigrant[2]=mean(data$VA_urbanmigrant, na.rm= TRUE)
dd$limits$VA_local_leader[2]=mean(data$VA_local_leader, na.rm= TRUE)
fm1m1clus.=update(fm1m1clus)
a=Predict(fm1m1clus., VA_lowincome_veh, fun=plogis, kint=1)
b=Predict(fm1m1clus., VA_lowincome_veh, fun=plogis, kint=2)
e=Predict(fm1m1clus., VA_lowincome_veh, fun=plogis, kint=3)
d=Predict(fm1m1clus., VA_lowincome_veh, fun=plogis, kint=4)

ggplot(a, ylim=range(0:1), xlim=(range(a$VA_lowincome_veh)),adj.subtitle = FALSE)+
  geom_line(aes(y=b$yhat, x=b$VA_lowincome_veh))+
  geom_line(aes(y=e$yhat, x=e$VA_lowincome_veh))+
  geom_line(aes(y=d$yhat, x=d$VA_lowincome_veh))+
  geom_ribbon(aes(ymin=b$lower,ymax=b$upper),alpha=0.3)+ 
  geom_ribbon(aes(ymin=e$lower,ymax=e$upper),alpha=0.3)+
  geom_ribbon(aes(ymin=d$lower,ymax=d$upper),alpha=0.3)+
  labs(y='Predicted Probability',title=" ", x='% Low income households in a valve area' )+
  annotate('text', x=0.1, y=c(.05, .20, .50,.75), label=c("y> =everyday", "y> =every 2 days", 'y> =every 3-4 days',"y> =every 4-5+ days"))


#Supplemental Figures and Tables#

#Figure SI.1. Religious and Economic Composition of VAs in BWSSB Subdivision E3----
a=tm_shape(valves) + 
  tm_fill("low.income", palette="Greys", title="Interval (Days)", colorNA=NULL)+tm_layout(main.title="Fraction Low Income Households in E3")+
  tm_layout(legend.outside = TRUE)


b=tm_shape(valves) + 
  tm_fill("muslim", palette="Greys", title="Interval (Days)", colorNA=NULL)+tm_layout(main.title="Fraction Muslim Households in E3")+
  tm_layout(legend.outside = TRUE)

tmap_arrange(a,b)

#Table SI.1.  Correlation matrix for independent variables------

IV=with(data, cbind.data.frame(elevation , cauvery_only ,urbanmigrant,congress,
                                muslim_family , low_income_veh  ,SCST2,  VA_urbanmigrant , VA_muslim ,VA_congress,
                                VA_lowincome_veh ,VA_SCST2, VA_local_leader,
                                comp,CorporatorAlignmentPre))
cor(IV)%>%round(., digits=2)




#Table SI.2. Duration of Water Supply, Eastern Bangalore, April-May 2015----

#Model 1
fm1m1 <- lrm(formula =Q208_decimal_wateron_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader , data=data, x=TRUE, y=TRUE)

fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)


#Model 2
fm1m2 <- lrm(formula = Q208_decimal_wateron_factor ~elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader+ 
               Ward, data=data, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)


#Model 3


fm1m3 <- lrm(formula = Q208_decimal_wateron_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)




#Model 4

fm1m4 <- lrm(formula = Q208_decimal_wateron_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40)



stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Duration of water when it comes on"),
          omit = "Ward",
          covariate.labels=c("y> = 2-3 hours", "y> =3-4 hours", 'y> =4+hours', "Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                             'Low income',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                             'Low Income (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          add.lines = list(c("Ward dummies", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))




#Table SI.3. Prevalence of Supply Cancellations, Eastern Bangalore, April-May 2015-----


#Model 1

fm1m1 <- lrm(formula =Q213_waterarrival_factor ~  elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader , data=data, x=TRUE, y=TRUE)


fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)





#Model 2

fm1m2 <- lrm(formula = Q213_waterarrival_factor ~  elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               Ward, data=data, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)


#Model 3

fm1m3 <- lrm(formula = Q213_waterarrival_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)




#Model 4

fm1m4 <- lrm(formula = Q213_waterarrival_factor ~  elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader+ 
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40)



stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Whether or not service is cancelled on supply days"),
          omit = "Ward",
          covariate.labels=c("y> =rarely", "y> =no", "Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                             'Low income',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                             'Low Income (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          add.lines = list(c("Ward dummies", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))



#Table SI.4. Water Pressure, Eastern Bangalore, April-May 2015----

#Model 1

fm1m1 <- lrm(formula =Q220a_pressure_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader , data=data, x=TRUE, y=TRUE)

fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)


#Model 2

fm1m2 <- lrm(formula = Q220a_pressure_factor~elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader+ 
               Ward, data=data, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)


#Model 3


fm1m3 <- lrm(formula = Q220a_pressure_factor ~elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader+
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)


fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)




#Model 4

fm1m4 <- lrm(formula = Q220a_pressure_factor ~elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader+
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)

fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40)



stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Water pressure level"),
          omit = "Ward",
          covariate.labels=c("y> =moderate", "y> =strong", "Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                             'Low income',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                             'Low Income (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          add.lines = list(c("Ward dummies", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))




#Table SI.5. Predictability of Water Supply in Eastern Bangalore, April-May 2015 (low income status replaced with SC/ST status)-----
#Model 1

fm1m1 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + SCST2  +  VA_urbanmigrant + VA_muslim +
               VA_SCST2 + VA_local_leader
             , data=data, x=TRUE, y=TRUE)


fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)




#Model 2

fm1m2 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + SCST2  +  VA_urbanmigrant + VA_muslim +
               VA_SCST2 + VA_local_leader + 
               Ward, data=data, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)




#Model 3

fm1m3 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + SCST2  +  VA_urbanmigrant + VA_muslim +
               VA_SCST2 + VA_local_leader + 
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)

fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)


#Model 4

fm1m4 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + SCST2  +  VA_urbanmigrant + VA_muslim +
               VA_SCST2 + VA_local_leader+ comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)


fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40, 
                     coef.reps=TRUE)


 
stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Whether water comes at a specific time "),
          covariate.labels=c("Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                                                 'SC/ST',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                                                 'SC/ST (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies?", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))




#Table SI.6. Water Supply Frequency, Eastern Bangalore, April-May 2015, April-May 2015 (low income status replaced with SC/ST status)

#Model 1

fm1m1 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + SCST2  +  VA_urbanmigrant + VA_muslim +
               VA_SCST2 + VA_local_leader , data=data, x=TRUE, y=TRUE)


fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)




#Model 2

fm1m2 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + SCST2  +  VA_urbanmigrant + VA_muslim +
               VA_SCST2 + VA_local_leader + 
               Ward, data=data, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)




#Model 3



fm1m3 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + elevation + cauvery_only +urbanmigrant+
               muslim_family + SCST2  +  VA_urbanmigrant + VA_muslim +
               VA_SCST2 + VA_local_leader+
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)




#Model 4

fm1m4 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + SCST2  +  VA_urbanmigrant + VA_muslim +
               VA_SCST2 + VA_local_leader+
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40, 
                     coef.reps=TRUE)




 
stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Interval between supply days"),
          covariate.labels=c("y> =every 4-5 days", "y> =every 3-4 days", 'y> =every 2 days',"y>=everyday","Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                             'SC/ST',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                             'SC/ST (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies?", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))







#Table SI.7. Predictability of Water Supply in Eastern Bangalore, April-May 2015 (Muslim family status replaced with INC Supporter status)-----

#Model 1


fm1m1 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               congress + low_income_veh  +  VA_urbanmigrant + VA_congress +
               VA_lowincome_veh + VA_local_leader , data=data, x=TRUE, y=TRUE)


fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)


#Model 2

fm1m2 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               congress + low_income_veh  +  VA_urbanmigrant + VA_congress +
               VA_lowincome_veh + VA_local_leader+
               Ward, data=data, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)




#Model 3


fm1m3 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               congress + low_income_veh  +  VA_urbanmigrant + VA_congress +
               VA_lowincome_veh + VA_local_leader+
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)




#Model 4


fm1m4 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               congress + low_income_veh  +  VA_urbanmigrant + VA_congress +
               VA_lowincome_veh + VA_local_leader+
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)





fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40, 
                     coef.reps=TRUE)


 
stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text",  style='apsr', star.cutoffs = c(0.05, 0.01,0.001),
          dep.var.labels=c("Whether water comes at a specific time"),
          covariate.labels=c("Elevation","Cauvery Supply","Urban Migrant", "Congress supporter",
                             'Low income',  "Urban Migrant (VA level)", 'Congress supporter (VA level)',
                             'Low Income (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))
     




#Table SI.8. Water Supply Frequency in Eastern Bangalore, April-May 2015 (Muslim family status replaced with INC Supporter status)----


#Model 1

fm1m1 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only+congress +
               low_income_veh  +VA_congress+
               VA_urbanmigrant + VA_lowincome_veh + VA_local_leader , data=data, x=TRUE, y=TRUE)



fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)


#Model 2

fm1m2 <- lrm(formula =Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               congress + low_income_veh  +  VA_urbanmigrant + VA_congress +
               VA_lowincome_veh + VA_local_leader + 
               Ward, data=data, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)


#Model 3


fm1m3 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               congress + low_income_veh  +  VA_urbanmigrant + VA_congress +
               VA_lowincome_veh + VA_local_leader + 
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)


#Model 4

fm1m4 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               congress + low_income_veh  +  VA_urbanmigrant + VA_congress +
               VA_lowincome_veh + VA_local_leader + 
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)

fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40)



stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text",  style='apsr', star.cutoffs = c(0.05, 0.01,0.001),
          dep.var.labels=c("Number of days a week with supply"),
          covariate.labels=c("y> =every 4-5","y> =every 3-4","y> =every 2 days","y> =everyday","Elevation","Cauvery Supply","Urban Migrant", "Congress supporter",
                             'Low income','Congress supporter',  "Urban Migrant (VA level)", 
                             'Low Income (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))
      

#Table SI.9. Predictability of Water Supply in Eastern Bangalore, April-May 2015 (Add SC/ST to model)-----


#Model 1

fm1m1 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only+urbanmigrant+muslim_family+
               low_income_veh + SCST2 + VA_urbanmigrant+ VA_muslim+
                VA_lowincome_veh + VA_SCST2+ VA_local_leader , data=data, x=TRUE, y=TRUE)


fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)

#Model 2

fm1m2 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only+urbanmigrant+muslim_family+
               low_income_veh + SCST2 + VA_urbanmigrant+ VA_muslim+
               VA_lowincome_veh + VA_SCST2+ VA_local_leader+
               Ward, data=data, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)




#Model 3


fm1m3 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only+urbanmigrant+muslim_family+
               low_income_veh + SCST2 + VA_urbanmigrant+ VA_muslim+
               VA_lowincome_veh + VA_SCST2+ VA_local_leader+
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)



#Model 4, add ward competition interaction to #3


fm1m4 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only+urbanmigrant+muslim_family+
               low_income_veh + SCST2 + VA_urbanmigrant+ VA_muslim+
               VA_lowincome_veh + VA_SCST2+ VA_local_leader+
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)


fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40, 
                     coef.reps=TRUE)

stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text",  style='apsr', star.cutoffs = c(0.05, 0.01,0.001),
          dep.var.labels=c("Whether water comes at a specific time"),
          covariate.labels=c("Elevation","Cauvery Supply","Urban Migrant", "Muslim Family",
                             'Low income', 'SC/ST',  "Urban Migrant (VA level)", 'Muslim Family (VA level)',
                             'Low Income (VA level)', 'SC/ST (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))


#Table SI.10. Water Supply Frequency in Eastern Bangalore, April-May 2015 (Add SC/ST to model)----

#Model 1

fm1m1 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only+urbanmigrant+muslim_family+
               low_income_veh + SCST2 + VA_urbanmigrant+ VA_muslim+
               VA_lowincome_veh + VA_SCST2+ VA_local_leader, data=data, x=TRUE, y=TRUE)



fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)


#Model 2

fm1m2 <- lrm(formula =Q205_pipedwaterdays_factor ~ elevation + cauvery_only+urbanmigrant+muslim_family+
               low_income_veh + SCST2 + VA_urbanmigrant+ VA_muslim+
               VA_lowincome_veh + VA_SCST2+ VA_local_leader+
               Ward, data=data, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)


#Model 3


fm1m3 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only+urbanmigrant+muslim_family+
               low_income_veh + SCST2 + VA_urbanmigrant+ VA_muslim+
               VA_lowincome_veh + VA_SCST2+ VA_local_leader+
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)


fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)




#Model 4

fm1m4 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only+urbanmigrant+muslim_family+
               low_income_veh + SCST2 + VA_urbanmigrant+ VA_muslim+
               VA_lowincome_veh + VA_SCST2+ VA_local_leader+
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40)





stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text",  style='apsr', star.cutoffs = c(0.05, 0.01,0.001),
          dep.var.labels=c("Number of days a week with supply"),
          covariate.labels=c("y> =every 4-5","y> =every 3-4 ","y> =every 2 days","y> =everyday","Elevation","Cauvery Supply","Urban Migrant", "Muslim Family",
                             'Low income', 'SC/ST',  "Urban Migrant (VA level)", 'Muslim Family (VA level)',
                             'Low Income (VA level)', 'SC/ST (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))





#Table SI.11. Predictability of Water Supply in Eastern Bangalore, April-May 2015 (CMC-only service households dropped)--

#Model 1

fm1m1 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader , data=data[data$cmc_supply_only==0,], x=TRUE, y=TRUE)


fm1m1clus <- bootcov(fm1m1, cluster=data$VA[data$cmc_supply_only==0], B=3000, maxit=40)



#Model 2

fm1m2 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader+
               Ward, data=data[data$cmc_supply_only==0,], x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)




#Model 3

fm1m3 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               CorporatorAlignmentPre, data=data[data$cmc_supply_only==0,], x=TRUE, y=TRUE)


fm1m3clus <- bootcov(fm1m3, cluster=data$VA[data$cmc_supply_only==0], B=3000, maxit=40)




#Model 4


fm1m4 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader+
               comp*CorporatorAlignmentPre, data=data[data$cmc_supply_only==0,], x=TRUE, y=TRUE)



fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40, 
                     coef.reps=TRUE)

stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Whether water arrives at a specific time "),
          covariate.labels=c("Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                             'Low income',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                             'Low Income (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))


#Table SI.12. Water Supply Frequency, Eastern Bangalore, April-May 2015 (CMC-only service households dropped)----


#Model 1

fm1m1 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader, data=data[data$cmc_supply_only==0,], x=TRUE, y=TRUE)



fm1m1clus <- bootcov(fm1m1, cluster=data$VA[data$cmc_supply_only==0], B=3000, maxit=40)




#Model 2

fm1m2 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               Ward, data=data[data$cmc_supply_only==0,], x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)


#Model 3



fm1m3 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               CorporatorAlignmentPre, data=data[data$cmc_supply_only==0,], x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=data$VA[data$cmc_supply_only==0], B=3000, maxit=40)




#Model 4

fm1m4 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               comp*CorporatorAlignmentPre, data=data[data$cmc_supply_only==0,], x=TRUE, y=TRUE)



fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40)



stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Number of days a week with supply"),
          covariate.labels=c( covariate.labels=c("y> =every 4-5 days", "y> =every 3-4 days", 'y> =every 2 days',"y>=everyday","Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                                                 'Low income',  "Urban Migrant", 'Muslim',
                                                 'Low Income', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
                              
                              'Urban Migrant (VA level)', 'Low Income (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies?", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))




#Table SI.13. Predictability of Water Supply in Eastern Bangalore, April-May 2015 (VAs with poor survey coverage dropped)----



datacov=data[!(data$coverage == 'poor'),]
datacov$Ward=droplevels(datacov$Ward)
fm1m1 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader , data=datacov, x=TRUE, y=TRUE)


fm1m1clus <- bootcov(fm1m1, cluster=datacov$VA, B=3000, maxit=40)



#Model 2

fm1m2 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader+
               Ward, data=datacov, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)




#Model 3



fm1m3 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               CorporatorAlignmentPre, data=datacov, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=datacov$VA, B=3000, maxit=40)






stargazer(fm1m1clus,fm1m2clus,fm1m3clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Whether water arrives at a specific time "),
          covariate.labels=c("Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                             'Low income',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                             'Low Income (VA level)', 'Local leader','INC Corporator'),
          omit = "Ward",
          add.lines = list(c("Ward dummies", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))


#Table SI.14. Water Supply Frequency in Eastern Bangalore, April-May 2015 (VAs with poor survey coverage dropped)----


#Model 1

fm1m1 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader, data=datacov, x=TRUE, y=TRUE)



fm1m1clus <- bootcov(fm1m1, cluster=datacov$VA, B=3000, maxit=40)




#Model 2

fm1m2 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               Ward, data=datacov, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)


#Model 3

fm1m3 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               CorporatorAlignmentPre, data=datacov, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=datacov$VA, B=3000, maxit=40)




stargazer(fm1m1clus,fm1m2clus,fm1m3clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Number of days a week with supply"),
          covariate.labels=c("y> =every 4-5 days", "y> =every 3-4 days", 'y> =every 2 days',"y>=everyday","Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                             'Low income',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                             'Low Income (VA level)', 'Local leader','INC Corporator'),
          
          omit = "Ward",
          add.lines = list(c("Ward dummies?", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))








#Table SI.15. Predictability of Water Supply in Eastern Bangalore, April-May 2015 (households with self-filling tanks dropped)----
notanks=subset(data, !Q204_storagetankyesno==1 |is.na(Q204_storagetankyesno))

#Model 1

fm1m1 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader , data=notanks, x=TRUE, y=TRUE)


fm1m1clus <- bootcov(fm1m1, cluster=notanks$VA, B=3000, maxit=40)




#Model 2

fm1m2 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader+
               Ward, data=notanks, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)




#Model 3



fm1m3 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               CorporatorAlignmentPre, data=notanks, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=notanks$VA, B=3000, maxit=40)




#Model 4

fm1m4 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader+
               comp*CorporatorAlignmentPre,data=notanks, x=TRUE, y=TRUE)





fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40, 
                     coef.reps=TRUE)




 
stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Whether water comes at a specific time (no self-filling tanks)"),
          covariate.labels=c("Elevation","Cauvery Supply",  "Muslim",
                             'Low income', 'Elevation', 'Muslim',
                             'Urban Migrant (VA level)', 'Low Income (VA level)', 
                             'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies?", "No", "Yes","No","No")))





#Table SI.16. Water Supply Frequency in Eastern Bangalore, April- May 2015 (households with self-filling tanks dropped)-----

#Model 1
fm1m1 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader, data=notanks, x=TRUE, y=TRUE)



fm1m1clus <- bootcov(fm1m1, cluster=notanks$VA, B=3000, maxit=40)




#Model 2

fm1m2 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               Ward, data=notanks, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)



#Model 3



fm1m3 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               CorporatorAlignmentPre, data=notanks, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=notanks$VA, B=3000, maxit=40)




#Model 4

fm1m4 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family + low_income_veh  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome_veh + VA_local_leader + 
               comp*CorporatorAlignmentPre, data=notanks, x=TRUE, y=TRUE)



fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40)




stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Number of days a week with supply"),
          covariate.labels=c( covariate.labels=c("y> =every 4-5 days", "y> =every 3-4 days", 'y> =every 2 days',"y>=everyday","Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                                                 'Low income',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                                                 'Low Income (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
                              
                              'Urban Migrant', 'Low Income', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies?", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))








#Table SI.17. Predictability of Water Supply in Eastern Bangalore, April-May 2015 (<Rs 10,000 monthly income used for low-income categorization)----





fm1m1 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family +low_income  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome+ VA_local_leader , data=data, x=TRUE, y=TRUE)


fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)




#Model 2

fm1m2 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family +low_income  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome+ VA_local_leader+
               Ward, data=data, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)




#Model 3



fm1m3 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family +low_income  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome+ VA_local_leader + 
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)




#Model 4


fm1m4 <- lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family +low_income  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome+ VA_local_leader+
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)





fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40, 
                     coef.reps=TRUE)




 
stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Whether water arrives at a specific time "),
          covariate.labels=c("Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                             'Low income',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                             'Low Income (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))


#Table SI.18. Water Supply Frequency in Eastern Bangalore, April- May 2015 (<Rs 10,000 monthly income used for low-income categorization)----






#Model 1

fm1m1 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family +low_income  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome+ VA_local_leader, data=data, x=TRUE, y=TRUE)



fm1m1clus <- bootcov(fm1m1, cluster=data$VA, B=3000, maxit=40)





#Model 2

fm1m2 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family +low_income  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome+ VA_local_leader + 
               Ward, data=data, x=TRUE, y=TRUE)

fm1m2clus <- bootcov(fm1m2, B=3000, maxit=40)


#Model 3


fm1m3 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family +low_income  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome+ VA_local_leader + 
               CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m3clus <- bootcov(fm1m3, cluster=data$VA, B=3000, maxit=40)




#Model 4

fm1m4 <- lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
               muslim_family +low_income  +  VA_urbanmigrant + VA_muslim +
               VA_lowincome+ VA_local_leader + 
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)



fm1m4clus <- bootcov(fm1m4, B=3000, maxit=40)




stargazer(fm1m1clus,fm1m2clus,fm1m3clus,fm1m4clus,no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Number of days a week with supply"),
          covariate.labels=c( covariate.labels=c("y> =every 4-5 days", "y> =every 3-4 days", 'y> =every 2 days',"y>=everyday","Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                                                 'Low income',  "Urban Migrant (VA level)", 'Muslim (VA level)',
                                                 'Low Income (VA level)', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
                              
                              'Urban Migrant', 'Low Income', 'Local leader',"Margin of victory",'INC Corporator',"Margin X INC Corp."),
          omit = "Ward",
          add.lines = list(c("Ward dummies?", "No", "Yes","No","No"),c("SEs clustered at VA", "Yes", "No","Yes","No")))



#Table SI.19. Water Supply Predictability and Frequency in Eastern Bangalore, April- May 2015 (no VA characteristics)----

#Predictability
base=lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only + urbanmigrant+
           muslim_family + low_income_veh  , data=data, x=TRUE, y=TRUE)


baseSE=bootcov(base, B=3000, maxit=40)



base2=lrm(formula = Q209_water_time_factor ~ elevation + cauvery_only + urbanmigrant+
            muslim_family + low_income_veh + 
            comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)

base2SE=bootcov(base2, B=3000, maxit=40) 




#Frequency

dv2base=lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only +urbanmigrant+
              muslim_family + low_income_veh  , data=data, x=TRUE, y=TRUE)


dv2baseSE=bootcov(dv2base, B=3000, maxit=40)





dv2base2=lrm(formula = Q205_pipedwaterdays_factor ~ elevation + cauvery_only + urbanmigrant+
               muslim_family + low_income_veh + 
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)

dv2base2SE=bootcov(dv2base2, B=3000, maxit=40) 


stargazer(baseSE,base2SE,dv2baseSE,dv2base2SE, no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001),
          
          covariate.labels=c("y> =every 4-5 days", "y> =every 3-4 days", 'y> =every 2 days',"y>=everyday","Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                             'Low income','Margin of victory',  'INC Corporator', "Margin X INC Corp."),
          dep.var.labels=c("Whether water comes at a certain time","Supply Frequency",ord.intercepts = FALSE)
          
)


#Table SI.20. Duration of Water Supply, Prevalence of Cancellations, and Water Pressure, Eastern Bangalore, April-May 2015 (no VA characteristics)----

#Duration

dv3base=lrm(formula =Q208_decimal_wateron_factor ~ elevation + cauvery_only +urbanmigrant+
              muslim_family + low_income_veh  , data=data, x=TRUE, y=TRUE)


dv3baseSE=bootcov(dv3base, B=3000, maxit=40)





dv3base2=lrm(formula =Q208_decimal_wateron_factor ~ elevation + cauvery_only + urbanmigrant+
               muslim_family + low_income_veh + 
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)

dv3base2SE=bootcov(dv3base2, B=3000, maxit=40) 





#Cancellatioins

dv4base=lrm(formula = Q213_waterarrival_factor ~ elevation + cauvery_only +urbanmigrant+
              muslim_family + low_income_veh  , data=data, x=TRUE, y=TRUE)


dv4baseSE=bootcov(dv4base, B=3000, maxit=40)





dv4base2=lrm(formula =Q213_waterarrival_factor ~ elevation + cauvery_only + urbanmigrant+
               muslim_family + low_income_veh + 
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)

dv4base2SE=bootcov(dv4base2, B=3000, maxit=40) 




#Pressure

dv5base=lrm(formula = Q220a_pressure_factor ~ elevation + cauvery_only +urbanmigrant+
              muslim_family + low_income_veh  , data=data, x=TRUE, y=TRUE)


dv5baseSE=bootcov(dv5base, B=3000, maxit=40)





dv5base2=lrm(formula =Q220a_pressure_factor ~ elevation + cauvery_only + urbanmigrant+
               muslim_family + low_income_veh + 
               comp*CorporatorAlignmentPre, data=data, x=TRUE, y=TRUE)

dv5base2SE=bootcov(dv5base2, B=3000, maxit=40) 

stargazer(dv3baseSE,dv3base2SE,dv4baseSE,dv4base2SE, dv5baseSE,dv5base2SE, no.space=TRUE,type="text", style='apsr', star.cutoffs = c(0.05, 0.01,0.001), 
          dep.var.labels=c("Duration of water when it arrives",
                           "Prevalence of supply cancellations", "Water Pressure"),
          covariate.labels=c("y> =2-3 hours", "y> =every 3-4 hours", 'y> =every 4+ hours',"y>=rarely","y>=no",
                              "y>=moderate","y>=strong",
                             
                             "Elevation","Cauvery Supply","Urban Migrant", "Muslim",
                             'Low income','Margin of victory',  'INC Corporator', "Margin X INC Corp.")
          
)


#Table SI.21.  Crosstab of water arrival frequency and duration for survey respondents,  Eastern Bangalore, April-May 2015----



prop.table(table(data$Q205_pipedwaterdays_factor,data$Q208_decimal_wateron_factor),1)%>%round(.,digits=3)




